#include "QCefHideExtWidget.h"


//////////////////////////////////////////////////////////////////////////
//
QCefHideExtWidget::QCefHideExtWidget(bool bHide, QWidget * parent, Qt::WindowFlags flags)
    : QCefExtWidget(parent, flags)
{
    QCEF_DEBUG();

    //
    if (bHide)
    {
        initHide();
    }
}

QCefHideExtWidget::QCefHideExtWidget(const QString & strUrl, bool bHide, QWidget * parent, Qt::WindowFlags flags)
    : QCefExtWidget(strUrl, parent, flags)
{
    QCEF_DEBUG();

    //
    if (bHide)
    {
        initHide();
    }
}

QCefHideExtWidget::~QCefHideExtWidget()
{
    QCEF_DEBUG();
}


int QCefHideExtWidget::initHide()
{
    //
    this->setWindowTitle("QCefHideExtWidget");

    this->setAttribute(Qt::WA_Disabled);
    this->setAttribute(Qt::WA_UpdatesDisabled);
    this->setAttribute(Qt::WA_ForceDisabled);
    this->setAttribute(Qt::WA_ForceUpdatesDisabled);
    this->setAttribute(Qt::WA_NoChildEventsFromChildren);
    this->setAttribute(Qt::WA_NoChildEventsForParent);
    this->setAttribute(Qt::WA_WState_Hidden);
    this->setAttribute(Qt::WA_ShowWithoutActivating);

    this->setDisabled(true);
    this->setVisible(false);

    return 0;
}

void QCefHideExtWidget::firstPolishEvent(QEvent * event)
{
    QCEF_DEBUG();

    DWORD style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED;
    DWORD ex_style = WS_EX_NOACTIVATE;
    //this->setGeometry(-10240, -10240, 2048, 2048);
    //this->setGeometry(48, 48, 1024, 768);

    this->createContainer();
    this->createClient();
    this->createBrowser(this->getFirstUrl(), QSize(1024, 768), style, ex_style);

    //不需要调用基类的函数
    //__super::firstPolishEvent(event);
}


void QCefHideExtWidget::hideWidget()
{
    this->setGeometry(-10240, -10240, 2048, 2048);
    this->hide();
}

void QCefHideExtWidget::showWidget()
{
    this->setGeometry(48, 48, 1024, 768);
    this->show();
}
